#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=200;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL dp[maxn][maxn];
LL pre[maxn];
char str[maxn];
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL n,k;cin>>n>>k;
   cin>>(str+1);
   for(LL i=1;i<=n;i++){
       for(LL j=i+1;j<=n;j++){
           if(str[i]==str[j]){
               pre[j]=i;
           }
       }
   }
   for(LL i=0;i<=n;i++){
       dp[i][0]=1;
   }
   for(LL i=1;i<=n;i++){
       for(LL j=1;j<=i;j++){
           dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
           if(pre[i]!=0) dp[i][j]-=dp[pre[i]-1][j-1];
       }
   }
   LL ans=0;
   for(LL i=n;i>=1&&k;i--){
       ans+=min(dp[n][i],k)*(n-i);
       k=max(k-dp[n][i],(LL)0);
   }
   if(k>1){cout<<"-1"<<"\n";return 0;}
   if(k==1) ans+=n;
   cout<<ans<<"\n";
   return 0;
}
